package Gui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.net.MalformedURLException;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import Main.Defines;

public class GameBoardPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2390298547096184354L;
	private static GameBoardPanel ref;
	private Image background;
	private Dimension size;

	private GameBoardPanel() {
		setName("GameBoardPanel");
		// setLayout(new BorderLayout());
		try
		{
			background = new ImageIcon(new URL("http://www.stevenbankhead.com/GSP_Project/Images/Gameboard2.jpg")).getImage();
		} catch (MalformedURLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		size = new Dimension(background.getWidth(null), background
				.getHeight(null));
		setSize(size);
		setMinimumSize(size);
	}

	public static GameBoardPanel getInstance() {
		if (ref == null) {
			ref = new GameBoardPanel();
		}
		return ref;
	}

	public void update() {
	}

	public void paintComponent(Graphics g) {
		// maybe set size for image
		g.drawImage(background, 0, 0, null);

		// draw player icon in accordance to background size
		for (int i = 0; i < Defines.PLM.getPlayerList().size(); i++) {
			Defines.PLM.getPlayerList().get(i).DrawPlayer(g,
					background.getHeight(null), background.getWidth(null),
					Defines.GM.getWeeksPerMonth(), Defines.GM.getDaysPerWeek());
		}
	}
}
